﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Chinesys.DataModel;
using Chinesys.Entities;

namespace Chinesys.Domain.DataMapper
{
    public static class OrderDataMapper
    {
        public static OrderEntity OrderFromRowToEntity(Order row)
        {
            OrderEntity entity;

            if (row != null)
            {
                entity = new OrderEntity();
                entity.CustomerId = row.CustomerId;
                entity.DateBegin = row.DateBegin;
                entity.DateFinished = row.DateFinished;
                entity.DolarPrice = row.DolarPrice;
                entity.Id = row.Id;
                entity.CurrentState = RowState.Original;
            }
            else
                entity = null;

            return entity;
        }

        public static Order OrderFromEntityToRow(OrderEntity entity)
        {
            Order row;

            if (entity != null)
            {
                row = new Order();
                row.CustomerId = entity.CustomerId;
                row.DateBegin = entity.DateBegin;
                row.DateFinished = entity.DateFinished;
                row.DolarPrice = entity.DolarPrice;
                row.Id = entity.Id;
            }
            else
                row = null;

            return row;
        }
    }
}
